<html>
<head><meta charset="utf-8"><title>mir::VarBindingForm::opt_ty_info always None · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/mir.3A.3AVarBindingForm.3A.3Aopt_ty_info.20always.20None.html">mir::VarBindingForm::opt_ty_info always None</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="240685400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/mir%3A%3AVarBindingForm%3A%3Aopt_ty_info%20always%20None/near/240685400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> fee1-dead <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/mir.3A.3AVarBindingForm.3A.3Aopt_ty_info.20always.20None.html#240685400">(May 29 2021 at 05:46)</a>:</h4>
<p>I am trying to fix <a href="https://github.com/rust-lang/rust/issues/85765">an issue</a> where borrowck suggests invalid code, here is the code snippet:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">test</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Vec</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">rofl</span>: <span class="kp">&amp;</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="kt">i32</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">test</span><span class="p">;</span><span class="w"> </span><span class="c1">// &lt;- originally suggested &amp;mut mut test</span>

<span class="w">    </span><span class="n">rofl</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="nb">Vec</span>::<span class="n">new</span><span class="p">());</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>I believe I have fixed this issue, however, it highlights the local variable instead of specified type:</p>
<div class="codehilite"><pre><span></span><code>LL |     let rofl: &amp;Vec&lt;Vec&lt;i32&gt;&gt; = &amp;mut test;
   |         ---- help: consider changing this to be a mutable reference: `&amp;mut Vec&lt;Vec&lt;i32&gt;&gt;`
</code></pre></div>
<p>The suggestion logic uses <code>opt_ty_info</code> of <code>mir::VarBindingForm</code>.</p>
<p>It only highlights the declaration when <code>opt_ty_info</code> is <code>None</code>. Why is it <code>None</code> when user has an actual specified type? Should I fix this before I submit the PR? If not, I will have to add a UI test with an improperly highlighted suggestion.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>